package org.oc.qaq.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import org.oc.qaq.dto.UserLoginDTO;
import org.oc.qaq.dto.UserRegisterDTO;
import org.oc.qaq.result.Result;
import org.oc.qaq.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@Tag(name = "用户认证接口")
@RestController
@RequestMapping("/api/v1/auth")
public class AuthorizeController {

    @Autowired
    private UserService userService;

    @Operation(summary = "用户登录接口")
    @PostMapping("/login")
    public ResponseEntity<?> login(@RequestBody UserLoginDTO userLoginDTO) {
        return userService.login(userLoginDTO);
    }

    @Operation(summary = "用户注册接口")
    @PostMapping("/register")
    public Result<String> register(@RequestBody UserRegisterDTO userRegisterDTO) {
        return userService.register(userRegisterDTO);
    }

     @Operation(summary = "用户登出接口")
     @PostMapping("/logout")
     public Result<?> logout(HttpServletRequest request) {
        return userService.logout(request);
     }


}
